home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 July / CHIP 2006-07.2.iso / program / web_gelistirme / easyphp1-7_setup.exe / {app} / php / pear / go-pear.php
Encoding:
PHP Script  |  2003-08-24  |  68.4 KB  |  2,317 lines

  1. <?php //; echo; echo "YOU NEED TO RUN THIS SCRIPT WITH PHP NOW!"; echo; echo "Try this: lynx -source http://pear.php.net/go-pear | php -q"; echo; exit # -*- PHP -*-
  2. # +----------------------------------------------------------------------+
  3. # | PHP Version 4                                                        |
  4. # +----------------------------------------------------------------------+
  5. # | Copyright (c) 1997-2002 The PHP Group                                |
  6. # +----------------------------------------------------------------------+
  7. # | This source file is subject to version 2.02 of the PHP license,      |
  8. # | that is bundled with this package in the file LICENSE, and is        |
  9. # | available at through the world-wide-web at                           |
  10. # | http://www.php.net/license/2_02.txt.                                 |
  11. # | If you did not receive a copy of the PHP license and are unable to   |
  12. # | obtain it through the world-wide-web, please send a note to          |
  13. # | license@php.net so we can mail you a copy immediately.               |
  14. # +----------------------------------------------------------------------+
  15. # | Authors: Tomas V.V.Cox <cox@idecnet.com>                             |
  16. # |          Stig Sµther Bakken <stig@php.net>                           |
  17. # |             Christian Dickmann <dickmann@php.net>                         |
  18. # |             Pierre-Alain Joye <pajoye@pearfr.org>                         |
  19. # +----------------------------------------------------------------------+
  20. # $Id: go-pear,v 1.48 2003/08/12 21:44:02 pajoye Exp $
  21. #
  22. # Automatically download all the files needed to run the "pear" command
  23. # (the PEAR package installer).  Requires PHP 4.1.0 or newer.
  24. #
  25. # Installation: Linux
  26. #
  27. # This script can either be directly launched or passed via lynx like this.
  28. #
  29. #  $ lynx -source http://pear.php.net/go-pear | php
  30. #
  31. # The above assumes your php binary is named php and that it's
  32. # executable through your PATH:
  33. #
  34. # Installation: Windows
  35. #
  36. # On Windows, go-pear uses stdin for user input, so you must download
  37. # go-pear first and then run it:
  38. #
  39. # Note: In PHP 4.2.0-4.2.3, the PHP CLI binary is named php-cli.exe while since
  40. # PHP 4.3.0, it's simply named php.exe in the cli/ folder of your PHP directory.
  41. # The CGI is also named php.exe but it sits directly in your PHP directory.
  42. #
  43. #  > cli/php -r 'readfile("http://pear.php.net/go-pear");' > go-pear
  44. #  > cli/php go-pear
  45. #
  46. # Installation: Notes
  47. #
  48. # - If using the CGI version of PHP, append the -q option to suppress
  49. #   headers in the output.
  50. # - Once the go-pear script is initiated, you will see instructions on
  51. #   how to continue installing PEAR.  The first thing you should see is:
  52. #
  53. #   Welcome to go-pear!
  54. #
  55. # Installation: Web browser
  56. #
  57. # You can now use go-pear via a webbrowser, thanks to Christian Dickmann. It is
  58. # still beta codes, but feel free to test it:
  59. # 1.: Download the go-pear script by using the "Save target as ..." function
  60. # of your browser here.
  61. #
  62. # 2.: Place the go-pear file somewhere under the document root of your webserver.
  63. # The easiest way is to create a new directory for pear and to put the file in there.
  64. # Be sure your web server is setup to recognize PHP, and that you use an appropriate 
  65. # extension.  For example, you might name this file gopear.php
  66. #
  67. # 3.: Access go-pear through your webserver and follow the instructions. Please
  68. # make sure that PHP has write access to the dir you want to install PEAR into.
  69. # For example: http://localhost/pear/gopear.php
  70. #
  71. # 4.: After running go-pear you get a link to the Web Frontend of the PEAR installer.
  72. # I suggest bookmarking this link.
  73. #
  74. # 5.: Protect the Web Frontend directory and the go-pear script with a password.
  75. # Use .htaccess on Apache webservers for example.
  76. #
  77. #
  78. $sapi_name = php_sapi_name();
  79. set_time_limit(0);
  80. @ob_end_flush();
  81. ob_implicit_flush(true);
  82. define('WEBINSTALLER', (php_sapi_name() != 'cli' && !( substr(php_sapi_name(),0,3)=='cgi' && !isset($_SERVER['GATEWAY_INTERFACE']))));
  83.  
  84. ini_set('track_errors', true);
  85. ini_set('html_errors', WEBINSTALLER);
  86. ini_set('magic_quotes_runtime', false);
  87. error_reporting( E_ALL & ~E_NOTICE);
  88. define('WINDOWS', (substr(PHP_OS, 0, 3) == 'WIN'));
  89. define('GO_PEAR_VER', '0.2.2');
  90.  
  91. define('WIN32GUI', !WEBINSTALLER && WINDOWS && php_sapi_name()== 'cli' && which('cscript'));
  92.  
  93. /**
  94.  * See bug #23069
  95.  */
  96.  
  97. if ( WEBINSTALLER && WINDOWS ) {
  98.     $php_sapi_name = win32DetectPHPSAPI();
  99.     if($php_sapi_name=='cgi'){
  100.     $msg = nl2br("
  101. Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.
  102. Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the
  103. instructions) or use the CLI (cli\php.exe) in the console.
  104. ");
  105.         displayHTML('error', $msg);
  106.     }
  107. }
  108.  
  109. if (WEBINSTALLER && isset($_GET['action']) && $_GET['action'] == 'img' && isset($_GET['img'])) {
  110.     switch ($_GET['img'])
  111.     {
  112.         case 'note':
  113.         case 'pearlogo':
  114.         case 'smallpear':
  115.             showImage($_GET['img']);
  116.             exit;
  117.         default:
  118.             exit;
  119.     };
  120. }
  121.  
  122. // Check if PHP version is sufficient
  123. if (!function_exists("version_compare")) {
  124.     die("Sorry!  Your PHP version is too old.  PEAR and this script requires at
  125. least PHP 4.1.0 for stable operation.
  126.  
  127. It may be that you have a newer version of PHP installed in your web
  128. server, but an older version installed as the 'php' command.  In this
  129. case, you need to rebuilt PHP from source.
  130.  
  131. If your source is 4.1.x, you need to run 'configure' without any SAPI
  132. options such as --with-apache.  After rebuilding you will find the
  133. 'php' binary in the top-level directory.
  134.  
  135. If your source is 4.2.x, you need to run 'configure' with the
  136. --enable-cli option, rebuild and copy sapi/cli/php somewhere.
  137.  
  138. If your source is 4.3.x or newer, just make sure you don't run
  139. 'configure' with --disable-cli, rebuilt and copy sapi/cli/php.
  140.  
  141. Please upgrade PHP to a newer version, and try again.  See you then.
  142.  
  143. ");
  144. }
  145.  
  146. $installer_packages = array(
  147.     'PEAR',
  148.     'Archive_Tar',
  149.     'Console_Getopt',
  150.     'XML_RPC'
  151.     );
  152. if (WEBINSTALLER) {
  153.     $installer_packages[] = 'Pager';
  154.     $installer_packages[] = 'HTML_Template_IT';
  155.     $installer_packages[] = 'Net_UserAgent_Detect';
  156.     $installer_packages[] = 'PEAR_Frontend_Web';
  157. }
  158. $pfc_packages = array(
  159.     'DB',
  160.     'Net_Socket',
  161.     'Net_SMTP',
  162.     'Mail',
  163.     'XML_Parser',
  164.     'phpUnit'
  165.     );
  166. $config_desc = array(
  167.     'prefix' => 'Installation prefix',
  168.     'bin_dir' => 'Binaries directory',
  169.     'php_dir' => 'PHP code directory ($php_dir)',
  170.     'doc_dir' => 'Documentation base directory',
  171.     'data_dir' => 'Data base directory',
  172.     'test_dir' => 'Tests base directory',
  173. );
  174. if(!WEBINSTALLER && WINDOWS){
  175.     $config_desc['php_bin'] = 'php.exe path';
  176. }
  177. if (WEBINSTALLER) {
  178.     $config_desc['cache_dir'] = 'PEAR Installer cache directory';
  179.     $config_desc['cache_ttl'] = 'Cache TimeToLive';
  180.     $config_desc['webfrontend_file'] = 'Filename of WebFrontend';
  181.     $config_desc['php_bin'] = "php.exe path, optional (CLI command tools)";
  182. }
  183.  
  184. if (my_env('HTTP_PROXY')) {
  185.     $http_proxy = my_env('HTTP_PROXY');
  186. } elseif (my_env('http_proxy')) {
  187.     $http_proxy = my_env('http_proxy');
  188. } else {
  189.     $http_proxy = '';
  190. }
  191.  
  192. register_shutdown_function('bail');
  193.  
  194. detect_install_dirs();
  195.  
  196. if (WEBINSTALLER) {
  197.     @session_start();
  198.  
  199.     /*
  200.         See bug #23069
  201.     */
  202.     if ( WINDOWS ) {
  203.         $php_sapi_name = win32DetectPHPSAPI();
  204.         if($php_sapi_name=='cgi'){
  205.             $msg = "
  206.     Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.
  207.     Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the
  208.     instructions) or use the CLI (cli\php.exe) in the console.
  209.     ";
  210.             displayHTML('error', $msg);
  211.             exit();
  212.         }
  213.     }
  214.  
  215.     if (!isset($_SESSION['go-pear']) || isset($_GET['restart'])) {
  216.         $sep = WINDOWS ? "\\" : '/';
  217.         $_SESSION['go-pear'] = array(
  218.             'http_proxy' => $http_proxy,
  219.             'config' => array(
  220.                 'prefix' => dirname(__FILE__),
  221.                 'bin_dir' => $bin_dir,
  222.                 'php_bin' => $php_bin,
  223.                 'php_dir' => '$prefix'.$sep.'PEAR',
  224.                 'doc_dir' => $doc_dir,
  225.                 'data_dir' => $data_dir,
  226.                 'test_dir' => $test_dir,
  227.                 'cache_dir' => '$php_dir'.$sep.'cache',
  228.                 'cache_ttl' => 300,
  229.                 'webfrontend_file' => '$prefix'.$sep.'index.php',
  230.                 ),
  231.             'install_pfc' => true,
  232.             'DHTML' => true,
  233.             );
  234.     }
  235.     if (!isset($_GET['step'])) {
  236.         $_GET['step'] = 'Welcome';
  237.         /* clean up old sessions datas */
  238.         session_destroy();
  239.     }
  240.     if ($_GET['step'] == 'install') {
  241.         $_SESSION['go-pear']['http_proxy'] = strip_magic_quotes($_POST['proxy']['host']).':'.strip_magic_quotes($_POST['proxy']['port']);
  242.         if ($_SESSION['go-pear']['http_proxy'] == ':') {
  243.             $_SESSION['go-pear']['http_proxy'] = '';
  244.         };
  245.  
  246.         $www_errors = array();
  247.         foreach($_POST['config'] as $key => $value) {
  248.             $_POST['config'][$key] = strip_magic_quotes($value);
  249.             if($key!='cache_ttl'){
  250.                 if( ereg(' ', $_POST['config'][$key]) ) {
  251.                     $www_errors[$key] = 'Spaces are not allowed in pathes. Please choose another path.';
  252.                 } elseif ( empty($_POST['config'][$key]) ) {
  253.                     $www_errors[$key] = 'Please fill this path, you can use $prefix, $php_dir or a full path.';
  254.                 }
  255.             }
  256.         }
  257.  
  258.         if( sizeof($www_errors)>0){
  259.             $_GET['step'] = 'config';
  260.         }
  261.  
  262.         $_SESSION['go-pear']['config'] = $_POST['config'];
  263.         $_SESSION['go-pear']['install_pfc'] = (isset($_POST['install_pfc']) && $_POST['install_pfc'] == 'on');
  264.         $_SESSION['go-pear']['DHTML'] = !($_POST['BCmode'] == "on");
  265.     }
  266.  
  267.     $http_proxy = $_SESSION['go-pear']['http_proxy'];
  268.     foreach($_SESSION['go-pear']['config'] as $var => $value) {
  269.         $$var = $value;
  270.     }
  271.     $install_pfc = $_SESSION['go-pear']['install_pfc'];
  272. }
  273.  
  274. if (!WEBINSTALLER) {
  275.     $tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r');
  276.  
  277.     if (!$tty) {
  278.         $tty = fopen('php://stdin', 'r');
  279.     }
  280.  
  281.     print "Welcome to go-pear!
  282.  
  283. Go-pear will install the 'pear' command and all the files needed by
  284. it.  This command is your tool for PEAR installation and maintenance.
  285.  
  286. Go-pear also lets you download and install the PEAR packages bundled
  287. with PHP: " . implode(', ', $pfc_packages) . ".
  288.  
  289. If you wish to abort, press Control-C now, or press Enter to continue: ";
  290.  
  291.     fgets($tty, 1024);
  292.  
  293.     print "\n";
  294.  
  295.         print "HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:";
  296.  
  297.     if (!empty($http_proxy)) {
  298.         print " [$http_proxy]";
  299.     }
  300.     print ": ";
  301.     $tmp = trim(fgets($tty, 1024));
  302.     if (!empty($tmp)) {
  303.         $http_proxy = $tmp;
  304.     }
  305. }
  306.  
  307. $origpwd = getcwd();
  308.  
  309. $config_vars = array_keys($config_desc);
  310.  
  311. // make indices run from 1...
  312. array_unshift($config_vars, "");
  313. unset($config_vars[0]);
  314. reset($config_vars);
  315. $desclen = max(array_map('strlen', $config_desc));
  316. $descfmt = "%-{$desclen}s";
  317. $first = key($config_vars);
  318. end($config_vars);
  319. $last = key($config_vars);
  320.  
  321. if (WEBINSTALLER) {
  322.     if ( isset($www_errors) && sizeof($www_errors) ) {
  323.         displayHTML('config');
  324.         exit();
  325.     } else {
  326.         if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'] == true && $_GET['step'] == 'install') {
  327.             $_GET['step'] = 'preinstall';
  328.         }
  329.         if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') {
  330.             displayHTML($_GET['step']);
  331.             exit;
  332.         }
  333.         if ($_GET['step'] == 'install-progress') {
  334.             displayHTMLHeader();
  335.             echo "Starting installation ...<br/>";
  336.         }
  337.         ob_start();
  338.     }
  339. }
  340.  
  341. $progress = 0;
  342.  
  343. /*
  344.  * Checks PHP SAPI version under windows/CLI
  345.  */
  346. if( WINDOWS && !WEBINSTALLER && $php_bin=='') {
  347.     print "
  348. We do not find any php.exe, please select the php.exe folder (CLI is
  349. recommanded, usually in c:\php\cli\php.exe)
  350. ";
  351.     $php_bin_set = false;
  352. } elseif ( WINDOWS && !WEBINSTALLER && strlen($php_bin) ) {
  353.     $php_bin_sapi = win32DetectPHPSAPI();
  354.     $php_bin_set = true;
  355.     switch($php_bin_sapi){
  356.         case 'cli':
  357.         break;
  358.         case 'cgi':
  359.             print "
  360. *NOTICE*
  361. We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI. PEAR commandline
  362. tool works well with it, if you have a CLI php.exe available, we
  363. recommand to use it.
  364. ";
  365.         break;
  366.         default:
  367.             print "
  368. *WARNING*
  369. We found php.exe under $php_bin, it uses an unknown SAPI. PEAR commandline
  370. tool has not been tested with it, if you have a CLI (or CGI) php.exe available,
  371. we strongly recommand to use it.
  372.  
  373. ";
  374.         break;
  375.     }
  376. }
  377.  
  378. ####
  379. # Temp stuff
  380. ####
  381.  
  382. $foo = tmp_dir();
  383. $ptmp = tempnam($foo, 'gope');
  384. if (WINDOWS) {
  385.     $ptmp = str_replace($foo,'',$ptmp);
  386.     $foo=str_replace("\\\\",'/',$foo);
  387.     $s = substr($ptmp,0,1);
  388.     if($s=="\\" || $s=='/' ){
  389.         $ptmp = $foo.'/'.substr($ptmp,1);
  390.     } else {
  391.         $ptmp = $foo.'/'.$ptmp;
  392.     }
  393. }
  394.  
  395. rm_rf($ptmp);
  396. mkdir_p($ptmp, 0700);
  397. $ok = @chdir($ptmp);
  398.  
  399. // If for some reason the user has no rights to access to
  400. // the standard tempdir, we assume that he has the right
  401. // to access his prefix and choose $prefix/tmp as tempdir
  402. if (!$ok) {
  403.     print "System's Tempdir failed, trying to use \$prefix/tmp ...";
  404.     $res = mkdir_p($prefix.'/tmp');
  405.     if (!$res) {
  406.         bail('mkdir '.$prefix.'/tmp'.' ... failed');
  407.     }
  408.     $ptmp = tempnam($prefix.'/tmp', 'gope');
  409.  
  410.     rm_rf($ptmp);
  411.     mkdir_p($ptmp, 0700);
  412.     $ok = @chdir($ptmp);
  413.  
  414.     if (!$ok) { // This should not happen, really ;)
  415.         bail('chdir '.$ptmp.' ... failed');
  416.     }
  417.  
  418.     print "ok\n";
  419.  
  420.     // Adjust TEMPDIR envvars
  421.     if (!isset($_ENV)) {
  422.         $_ENV = array();
  423.     };
  424.     $_ENV['TMPDIR'] = $_ENV['TEMP'] = $prefix.'/tmp';
  425. }
  426.  
  427. while (!WEBINSTALLER) {
  428.     print "
  429. Below is a suggested file layout for your new PEAR installation.  To
  430. change individual locations, type the number in front of the
  431. directory.  Type 'all' to change all of them or simply press Enter to
  432. accept these locations.
  433.  
  434. ";
  435.     if( WINDOWS && $php_bin=='' ){
  436.  
  437.     }
  438.     foreach ($config_vars as $n => $var) {
  439.         printf("%2d. $descfmt : %s\n", $n, $config_desc[$var], $$var);
  440.     }
  441.     print "\n$first-$last, 'all' or Enter to continue: ";
  442.     $tmp = trim(fgets($tty, 1024));
  443.     if ( empty($tmp) ) {
  444.         if( WINDOWS && !$php_bin_set ){
  445.             echo "**ERROR**
  446. Please, enter the php.exe path.
  447.  
  448. ";
  449.         } else {
  450.             break;
  451.         }
  452.     }
  453.     if (isset($config_vars[(int)$tmp])) {
  454.         $var = $config_vars[(int)$tmp];
  455.         $desc = $config_desc[$var];
  456.         $current = $$var;
  457.         if(WIN32GUI){
  458.             $tmp = win32BrowseForFolder("$desc [$current] :");
  459.         } else {
  460.             print "$desc [$current] : ";
  461.             $tmp = trim(fgets($tty, 1024));
  462.         }
  463.         $old = $$var;
  464.         if(WINDOWS && $var=='php_bin' ){
  465.             if(file_exists($tmp.DIRECTORY_SEPARATOR.'php.exe')){
  466.                 $tmp = $tmp.DIRECTORY_SEPARATOR.'php.exe';
  467.                 $php_bin_sapi = win32DetectPHPSAPI();
  468.                 if($php_bin_sapi=='cgi'){
  469.             print "
  470. ******************************************************************************
  471. NOTICE! We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI.
  472. PEAR commandline tool works well with it.
  473. If you have a CLI php.exe available, we recommand to use it.
  474.  
  475. ";
  476.                 } elseif ($php_bin_sapi=='unknown') {
  477.             print "
  478. ******************************************************************************
  479. WARNING! We found php.exe under $php_bin, it uses an $php_bin_sapi SAPI.
  480. PEAR commandline tool has not been tested with it.
  481. If you have a CLI (or CGI) php.exe available, we strongly recommand to use it.
  482.  
  483. ";
  484.                 }
  485.                 echo "php.exe (sapi: $php_bin_sapi) found.\n\n";
  486.                 $php_bin_set = true;
  487.             } else {
  488.                 echo "**ERROR**: no php.exe found in this folder.\n";
  489.                 $tmp='';
  490.             }
  491.         }
  492.  
  493.         if (!empty($tmp) ) {
  494.             $$var = $tmp;
  495.         }
  496.     } elseif ($tmp == 'all') {
  497.         foreach ($config_vars as $n => $var) {
  498.             $desc = $config_desc[$var];
  499.             $current = $$var;
  500.             print "$desc [$current] : ";
  501.             $tmp = trim(fgets($tty, 1024));
  502.             if (!empty($tmp)) {
  503.                 $$var = $tmp;
  504.             }
  505.         }
  506.     }
  507. }
  508.  
  509. foreach ($config_vars as $n => $var) {
  510.     foreach ($config_vars as $m => $var2) {
  511.         $$var = str_replace('$'.$var2, $$var2, $$var);
  512.     }
  513. }
  514.  
  515. foreach ($config_vars as $var) {
  516.     $dir = $$var;
  517.     if (!preg_match('/_dir$/', $var)) {
  518.         continue;
  519.     };
  520.     if (!@is_dir($dir)) {
  521.         if (!mkdir_p($dir)) {
  522.             $root = WINDOWS ? 'administrator' : 'root';
  523.             bail("Unable to create {$config_desc[$var]} $dir.
  524. Run this script as $root or pick another location.\n");
  525.         }
  526.     }
  527. }
  528.  
  529. if (!WEBINSTALLER) {
  530.     $msg = "The following PEAR packages are bundled with PHP: " .
  531.         implode(', ', $pfc_packages);
  532.     print "\n" . wordwrap($msg, 75) . ".\n";
  533.     print "Would you like to install these as well? [Y/n] : ";
  534.     $install_pfc = !stristr(fgets($tty, 1024), "n");
  535.     print "\n";
  536. }
  537.  
  538. ####
  539. # Download
  540. ####
  541.  
  542. ini_set("include_path", $ptmp);
  543.  
  544. if (!extension_loaded('zlib') && !WEBINSTALLER) { // In Web context we could be in multithread env which makes dl() end up with a fatal error.
  545.     if (WINDOWS) {
  546.         @dl('php_zlib.dll');
  547.     } elseif (PHP_OS == 'HP-UX') {
  548.         @dl('zlib.sl');
  549.     } elseif (PHP_OS == 'AIX') {
  550.         @dl('zlib.a');
  551.     } else {
  552.         @dl('zlib.so');
  553.     }
  554. }
  555. if (!extension_loaded('zlib')) {
  556.     $urltemplate = 'http://pear.php.net/get/%s?uncompress=yes';
  557.     $have_gzip = false;
  558. } else {
  559.     $urltemplate = 'http://pear.php.net/get/%s';
  560.     $have_gzip = true;
  561. }
  562. print "Loading zlib: ".($have_gzip ? 'ok' : 'failed')."\n";
  563. if (!$have_gzip) {
  564.     print "Downloading uncompressed packages\n";
  565. };
  566.  
  567. if ($install_pfc) {
  568.     $to_install = array_merge($installer_packages, $pfc_packages);
  569. } else {
  570.     $to_install = $installer_packages;
  571. }
  572.  
  573. displayHTMLProgress($progress = 5);
  574.  
  575. if (file_exists(dirname(__FILE__).'/go-pear-bundle') || is_dir(dirname(__FILE__).'/go-pear-bundle')) {
  576.     $dh = @opendir(dirname(__FILE__).'/go-pear-bundle');
  577. }
  578. $local_dir = array();
  579. if ($dh) {
  580.     while($file = @readdir($dh)) {
  581.         if ($file == '.' || $file == '..' || !is_file(dirname(__FILE__).'/go-pear-bundle/'.$file)) {
  582.             continue;
  583.         };
  584.         $local_dir[] = $file;
  585.     };
  586. }
  587.  
  588. foreach ($installer_packages as $pkg) {
  589.     foreach($local_dir as $file) {
  590.         if (substr($file, 0, strlen($pkg)) == $pkg) {
  591.             echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
  592.             copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
  593.             $tarball[$pkg] = $file;
  594.             echo "ok\n";
  595.             displayHTMLProgress($progress += round(65 / count($to_install)));
  596.             continue 2;
  597.         };
  598.     };
  599.  
  600.     $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
  601.     print $msg;
  602.     $url = sprintf($urltemplate, $pkg);
  603.     $tarball[$pkg] = download_url($url, null, $http_proxy);
  604.     print "ok\n";
  605.     displayHTMLProgress($progress += round(65 / count($to_install)));
  606. }
  607.  
  608. print 'Bootstrapping: PEAR...................';
  609. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['PEAR'], 5), 0, -4));
  610. $url = "http://cvs.php.net/co.php/php-src/pear/PEAR.php?p=1&r=$r";
  611. if (in_array('Getopt.php', $local_dir)) {
  612.     copy(dirname(__FILE__).'/go-pear-bundle/PEAR.php', 'PEAR.php');
  613.     echo "(local) ";
  614. } else {
  615.     download_url($url, 'PEAR.php', $http_proxy);
  616.     echo "(remote) ";
  617. }
  618.  
  619. include_once 'PEAR.php';
  620. print "ok\n";
  621.  
  622. print 'Bootstrapping: Archive_Tar............';
  623. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Archive_Tar'], 12), 0, -4));
  624. $url = "http://cvs.php.net/co.php/pear/Archive_Tar/Archive/Tar.php?p=1&r=$r";
  625. mkdir('Archive', 0700);
  626.  
  627. if (in_array('Getopt.php', $local_dir)) {
  628.     copy(dirname(__FILE__).'/go-pear-bundle/Tar.php', 'Archive/Tar.php');
  629.     echo "(local) ";
  630. } else {
  631.     download_url($url, 'Archive/Tar.php', $http_proxy);
  632.     echo "(remote) ";
  633. }
  634. print "ok\n";
  635.  
  636. print 'Bootstrapping: Console_Getopt.........';
  637. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Console_Getopt'], 15), 0, -4));
  638. $url = "http://cvs.php.net/co.php/php-src/pear/Console/Getopt.php?p=1&r=$r";
  639. mkdir('Console', 0700);
  640. if (in_array('Getopt.php', $local_dir)) {
  641.     copy(dirname(__FILE__).'/go-pear-bundle/Getopt.php', 'Console/Getopt.php');
  642.     echo "(local) ";
  643. } else {
  644.     download_url($url, 'Console/Getopt.php', $http_proxy);
  645.     echo "(remote) ";
  646. }
  647. print "ok\n";
  648.  
  649. if ($install_pfc) {
  650.     foreach ($pfc_packages as $pkg) {
  651.         foreach($local_dir as $file) {
  652.             if (substr($file, 0, strlen($pkg)) == $pkg) {
  653.                 echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
  654.                 copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
  655.                 $tarball[$pkg] = $file;
  656.                 echo "ok\n";
  657.                 displayHTMLProgress($progress += round(65 / count($to_install)));
  658.                 continue 2;
  659.             };
  660.         };
  661.  
  662.         $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
  663.         print $msg;
  664.         $url = sprintf($urltemplate, $pkg);
  665.         $tarball[$pkg] = download_url($url, null, $http_proxy);
  666.         print "ok\n";
  667.         displayHTMLProgress($progress += round(65 / count($to_install)));
  668.     }
  669. }
  670.  
  671. displayHTMLProgress($progress = 70);
  672.  
  673. PEAR::setErrorHandling(PEAR_ERROR_DIE, "\n%s\n");
  674. print 'Extracting installer..................';
  675. $dot = strrpos($tarball['PEAR'], '.');
  676. $pkg = substr($tarball['PEAR'], 0, $dot);
  677. $ext = substr($tarball['PEAR'], $dot+1);
  678.  
  679. include_once 'Archive/Tar.php';
  680. $tar = &new Archive_Tar($tarball['PEAR'], $have_gzip);
  681. if (!$tar->extractModify($ptmp, $pkg)) {
  682.     bail("failed!\n");
  683. }
  684. print "ok\n";
  685.  
  686. $tarball['PEAR'] = 'package.xml'; // :-)
  687.  
  688. include_once "PEAR.php";
  689. include_once "PEAR/Config.php";
  690. include_once "PEAR/Command.php";
  691. include_once "PEAR/Registry.php";
  692.  
  693. if (WEBINSTALLER) {
  694.     $config = &PEAR_Config::singleton($prefix."/pear.conf", '');
  695. } else {
  696.     $config = &PEAR_Config::singleton();
  697. };
  698. $config->set('preferred_state', 'stable');
  699. foreach ($config_vars as $var) {
  700.     $config->set($var, $$var);
  701. }
  702.  
  703. $config->store();
  704.  
  705. $registry = new PEAR_Registry($php_dir);
  706. PEAR_Command::setFrontendType('CLI');
  707. $install = &PEAR_Command::factory('install', $config);
  708. $install_options = array(
  709.     'nodeps' => true,
  710.     'force' => true,
  711.     );
  712. foreach ($tarball as $pkg => $src) {
  713.     $options = $install_options;
  714.     if ($registry->packageExists($pkg)) {
  715.         $options['upgrade'] = true;
  716.     }
  717.  
  718.     $install->run('install', $options, array($src));
  719.  
  720.     displayHTMLProgress($progress += round(29 / count($tarball)));
  721. }
  722.  
  723. displayHTMLProgress($progress = 99);
  724.  
  725. // Base installation finished
  726.  
  727. ini_restore("include_path");
  728.  
  729. if (!WEBINSTALLER) {
  730.     $sep = WINDOWS ? ';' : ':';
  731.     $include_path = explode($sep, ini_get('include_path'));
  732.     if (WINDOWS) {
  733.         $found = false;
  734.         $t = strtolower($php_dir);
  735.         foreach($include_path as $path) {
  736.             if ($t==strtolower($path)) {
  737.                 $found = true;
  738.                 break;
  739.             }
  740.         }
  741.     } else {
  742.         $found = in_array($php_dir, $include_path);
  743.     }
  744.     if (!$found) {
  745.         print "
  746. ******************************************************************************
  747. WARNING!  The include_path defined in the currently used php.ini does not
  748. contain the PEAR PHP directory you just specified:
  749. <$php_dir>
  750. If the specified directory is also not in the include_path used by
  751. your scripts, you will have problems getting any PEAR packages working.
  752. ";
  753.  
  754.         if ( $php_ini = getPhpiniPath() ) {
  755.             print "\n\nWould you like to alter php.ini <$php_ini>? [Y/n] : ";
  756.             $alter_phpini = !stristr(fgets($tty, 1024), "n");
  757.             if( $alter_phpini ) {
  758.                 alterPhpIni($php_ini);
  759.             } else {
  760.                 if (WINDOWS) {
  761.                     print "
  762. Please look over your php.ini file to make sure
  763. $php_dir is in your include_path.";
  764.                 } else {
  765.                     print "
  766. I will add a workaround for this in the 'pear' command to make sure
  767. the installer works, but please look over your php.ini or Apache
  768. configuration to make sure $php_dir is in your include_path.
  769. ";
  770.                 }
  771.  
  772.             }
  773.         }
  774.  
  775.     print "
  776. Current include path           : ".ini_get('include_path')."
  777. Configured directory           : $php_dir
  778. Currently used php.ini (guess) : $php_ini
  779. ";
  780.  
  781.         print "Press Enter to continue: ";
  782.         fgets($tty, 1024);
  783.     }
  784.  
  785.     $pear_cmd = $bin_dir . DIRECTORY_SEPARATOR . 'pear';
  786.  
  787.     // check that the installed pear and the one in tha path are the same (if any)
  788.     $pear_old = which('pear', $bin_dir);
  789.     if ($pear_old && $pear_old != $pear_cmd) {
  790.         // check if it is a link or symlink
  791.         $islink = WINDOWS ? is_link($pear_old) : false;
  792.         if ($islink && readlink($pear_old) != $pear_cmd) {
  793.             print "\n** WARNING! The link $pear_old does not point to the " .
  794.                   "installed $pear_cmd\n";
  795.         } elseif (is_writable($pear_old)) {
  796.             rename($pear_old, "{$pear_old}_old");
  797.             print "\n** WARNING! Backed up old pear to {$pear_old}_old\n";
  798.         } else {
  799.             print "\n** WARNING! Old version found at $pear_old, please remove it or ".
  800.                   "be sure to use the new $pear_cmd command\n";
  801.         }
  802.     }
  803.  
  804.     print "\nThe 'pear' command is now at your service at $pear_cmd\n";
  805.  
  806.     // Alert the user if the pear cmd is not in PATH
  807.     $old_dir = $pear_old ? dirname($pear_old) : false;
  808.     if (!which('pear', $old_dir)) {
  809.         print "
  810. ** The 'pear' command is not currently in your PATH, so you need to
  811. ** use '$pear_cmd' until you have added
  812. ** '$bin_dir' to your PATH environment variable.
  813.  
  814. ";
  815.  
  816.     print "Run it without parameters to see the available actions, try 'pear list'
  817. to see what packages are installed, or 'pear help' for help.
  818.  
  819. For more information about PEAR, see:
  820.  
  821.   http://pear.php.net/faq.php
  822.   http://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1
  823.   http://pear.php.net/manual/
  824.  
  825. Thanks for using go-pear!
  826.  
  827. ";
  828.     }
  829. }
  830.  
  831. if (WEBINSTALLER) {
  832.     print "Writing WebFrontend file ... ";
  833.        @unlink($webfrontend_file); //Delete old one
  834.     copy ( $doc_dir.DIRECTORY_SEPARATOR.
  835.             'PEAR_Frontend_Web'.DIRECTORY_SEPARATOR.
  836.             'docs'.DIRECTORY_SEPARATOR.
  837.             'example.php',
  838.             $webfrontend_file
  839.         );
  840.     if ($_GET['step'] == 'install-progress') {
  841.         displayHTMLProgress($progress = 100);
  842.         ob_end_clean();
  843.         displayHTMLInstallationSummary();
  844.         displayHTMLFooter();
  845.     } else {
  846.         $out = ob_get_contents();
  847.  
  848.         $out = explode("\n", $out);
  849.         foreach($out as $line => $value) {
  850.             if (preg_match('/ok$/', $value)) {
  851.                 $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  852.             };
  853.             if (preg_match('/^install ok:/', $value)) {
  854.                 $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  855.             };
  856.             if (preg_match('/^Warning:/', $value)) {
  857.                 $value = '<span style="color: #ff0000">'.$value.'</span>';
  858.             };
  859.             $out[$line] = $value;
  860.         };
  861.         $out = nl2br(implode("\n",$out));
  862.         ob_end_clean();
  863.  
  864.         displayHTML('install', $out);
  865.     }
  866.     // Little hack, this will be fixed in PEAR later
  867.     if ( WINDOWS ) {
  868.         clearstatcache();
  869.         @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear');
  870.     }
  871.     exit;
  872. }
  873.  
  874. // Little hack, this will be fixed in PEAR later
  875. if ( WINDOWS ) {
  876.     clearstatcache();
  877.     @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear');
  878. }
  879.  
  880. if (WINDOWS && !WEBINSTALLER) {
  881.     win32CreateRegEnv();
  882. }
  883. // Set of functions following
  884.  
  885. // {{{ download_url()
  886.  
  887. function download_url($url, $destfile = null, $proxy = null)
  888. {
  889.     $use_suggested_filename = ($destfile === null);
  890.     if ($use_suggested_filename) {
  891.         $destfile = basename($url);
  892.     }
  893.     $tmp = parse_url($url);
  894.     if (empty($tmp['port'])) {
  895.         $tmp['port'] = 80;
  896.     }
  897.     if (empty($proxy)) {
  898.         $fp = fsockopen($tmp['host'], $tmp['port'], $errno, $errstr);
  899.         //print "\nconnecting to $tmp[host]:$tmp[port]\n";
  900.     } else {
  901.         $tmp_proxy = parse_url($proxy);
  902.         $phost     = $tmp_proxy['host'];
  903.         $pport     = $tmp_proxy['port'];
  904.         $fp = fsockopen($phost, $pport, $errno, $errstr);
  905.         //print "\nconnecting to $phost:$pport\n";
  906.     }
  907.     if (!$fp) {
  908.         bail("download of $url failed: $errstr ($errno)\n");
  909.     }
  910.     if (empty($proxy)) {
  911.         $path = $tmp['path'];
  912.     } else {
  913.         $path = "http://$tmp[host]:$tmp[port]$tmp[path]";
  914.     }
  915.     if (isset($tmp['query'])) {
  916.         $path .= "?$tmp[query]";
  917.     }
  918.     if (isset($tmp['fragment'])) {
  919.         $path .= "#$tmp[fragment]";
  920.     }
  921.     $request = "GET $path HTTP/1.0\r\nHost: $tmp[host]:$tmp[port]\r\n".
  922.         "User-Agent: go-pear\r\n";
  923.  
  924.     if (!empty($proxy) && $tmp_proxy['user'] != '') {
  925.         $request .= 'Proxy-Authorization: Basic ' .
  926.                     base64_encode($tmp_proxy['user'] . ':' . $tmp_proxy['pass']) . "\r\n";
  927. //        print "\nauthenticating against proxy with : user = ${tmp_proxy['user']} \n";
  928. //        print "and pass = ${tmp_proxy['pass']}\n";
  929.     } // if
  930.     $request .= "\r\n";
  931.     fwrite($fp, $request);
  932.     $cdh = "content-disposition:";
  933.     $cdhl = strlen($cdh);
  934.     $content_length = 0;
  935.     while ($line = fgets($fp, 2048)) {
  936.         if (trim($line) == '') {
  937.             break;
  938.         }
  939.         if (preg_match('/^Content-Length: (.*)$/i', $line, $matches)) {
  940.             $content_length = trim($matches[1]);
  941.         };
  942.         if ($use_suggested_filename && !strncasecmp($line, $cdh, $cdhl)) {
  943.             if (eregi('filename="([^"]+)"', $line, $matches)) {
  944.                 $destfile = basename($matches[1]);
  945.             }
  946.         }
  947.     }
  948.     if ($content_length) {
  949.         displayHTMLSetDownload($destfile);
  950.     };
  951.     $wp = fopen($destfile, "wb");
  952.     if (!$wp) {
  953.         bail("could not open $destfile for writing\n");
  954.     }
  955.     $bytes_read = 0;
  956.     $progress = 0;
  957.     while ($data = fread($fp, 2048)) {
  958.         fwrite($wp, $data);
  959.         $bytes_read += strlen($data);
  960.         if ($content_length != 0 && floor($bytes_read * 10 / $content_length) != $progress) {
  961.             $progress = floor($bytes_read * 10 / $content_length);
  962.             displayHTMLDownloadProgress($progress * 10);
  963.         };
  964.     }
  965.     fclose($fp);
  966.     fclose($wp);
  967.     return $destfile;
  968. }
  969.  
  970. // }}}
  971. // {{{ which()
  972.  
  973. function which($program, $dont_search_in = false)
  974. {
  975.     if (WINDOWS) {
  976.         if ($_path=my_env('Path')) {
  977.             $dirs = explode(';', $_path);
  978.         } else {
  979.             $dirs = explode(';', my_env('PATH'));
  980.         }
  981.         if ($dont_search_in &&
  982.             ($key = array_search($dont_search_in, $dirs)) !== false)
  983.         {
  984.             unset($dirs[$key]);
  985.         }
  986.  
  987.         foreach ($dirs as $dir) {
  988.             $tmp = "$dir\\$program";
  989.             if (file_exists($ret = "$tmp.exe") ||
  990.                 file_exists($ret = "$tmp.com") ||
  991.                 file_exists($ret = "$tmp.bat") ||
  992.                 file_exists($ret = "$tmp.cmd")) {
  993.                 return $ret;
  994.             }
  995.         }
  996.     } else {
  997.         $dirs = explode(':', my_env('PATH'));
  998.         if ($dont_search_in &&
  999.             ($key = array_search($dont_search_in, $dirs)) !== false)
  1000.         {
  1001.             unset($dirs[$key]);
  1002.         }
  1003.         foreach ($dirs as $dir) {
  1004.             if (is_executable("$dir/$program")) {
  1005.                 return "$dir/$program";
  1006.             }
  1007.         }
  1008.     }
  1009.     return false;
  1010. }
  1011.  
  1012. // }}}
  1013. // {{{ bail()
  1014.  
  1015. function bail($msg = '')
  1016. {
  1017.     global $ptmp, $origpwd;
  1018.     if ($ptmp && is_dir($ptmp)) {
  1019.         chdir($origpwd);
  1020.         rm_rf($ptmp);
  1021.     }
  1022.     if ($msg && WEBINSTALLER) {
  1023.         $msg = @ob_get_contents() ."\n\n". $msg;
  1024.         @ob_end_clean();
  1025.         displayHTML('error', $msg);
  1026.         exit;
  1027.     };
  1028.     if ($msg && !WEBINSTALLER) {
  1029.         die($msg);
  1030.     }
  1031. }
  1032.  
  1033. // }}}
  1034. // {{{ mkdir_p()
  1035.  
  1036. function mkdir_p($dir, $mode = 0777)
  1037. {
  1038.     $lastdir = '';
  1039.     if (@is_dir($dir)) {
  1040.         return true;
  1041.     }
  1042.     $parent = dirname($dir);
  1043.     $parent_exists = (int)@is_dir($parent);
  1044.     $ok = true;
  1045.     if (!@is_dir($parent) && $parent != $dir) {
  1046.         $ok = mkdir_p(dirname($dir), $mode);
  1047.     }
  1048.     if ($ok) {
  1049.         $ok = @mkdir($dir, $mode);
  1050.         if (!$ok) {
  1051.             print "mkdir failed: $dir\n";
  1052.         }
  1053.     }
  1054.     return $ok;
  1055. }
  1056.  
  1057. // }}}
  1058. // {{{ rm_rf()
  1059.  
  1060. function rm_rf($path)
  1061. {
  1062.     if (@is_dir($path)) {
  1063.         $dp = opendir($path);
  1064.         while ($ent = readdir($dp)) {
  1065.             if ($ent == '.' || $ent == '..') {
  1066.                 continue;
  1067.             }
  1068.             $file = $path . DIRECTORY_SEPARATOR . $ent;
  1069.             if (@is_dir($file)) {
  1070.                 rm_rf($file);
  1071.             } else {
  1072.                 unlink($file);
  1073.             }
  1074.         }
  1075.         closedir($dp);
  1076.         return rmdir($path);
  1077.     } else {
  1078.         return @unlink($path);
  1079.     }
  1080. }
  1081.  
  1082. // }}}
  1083. // {{{ tmpdir()
  1084. /*
  1085.  * Fixes for winXP/wrong tmp set by Urs Gehrig (urs@circle.ch)
  1086.  */
  1087. function tmp_dir()
  1088. {
  1089.     if (WINDOWS){
  1090.         if ( my_env('TEMP') ) {
  1091.             $_temp = my_env('TEMP');
  1092.         } elseif ( my_env('TMP') ) {
  1093.             $_temp = my_env('TMP');
  1094.         } elseif ( my_env('windir') ) {
  1095.             $_temp = my_env('windir') . '\temp';
  1096.         } elseif ( my_env('SystemRoot') ) {
  1097.             $_temp = my_env('SystemRoot') . '\temp';
  1098.         }
  1099.  
  1100.         // handle ugly ENV var like \Temp instead of c:\Temp
  1101.         $dirs = explode("\\", realpath($_temp));
  1102.         if(strpos($_temp, ":") != 1) {
  1103.             unset($_temp);
  1104.             $_dirs = array();
  1105.             foreach($dirs as $key => $val) {
  1106.                 if((boolean)$val ) {
  1107.                     $_dirs[] = str_replace("/", "",  $val);
  1108.                 }
  1109.             }
  1110.             unset($dirs);
  1111.             $dirs = $_dirs;
  1112.             array_unshift ($dirs, "c:" );
  1113.             $_temp = $dirs[0];
  1114.             for($i = 1;$i < count($dirs);$i++) {
  1115.                 $_temp .= "//" . $dirs[$i];
  1116.             }
  1117.         }
  1118.         $ptmp = $_temp;
  1119.         return $_temp;
  1120.     }
  1121.     if (my_env('TMPDIR')) {
  1122.         return my_env('TMPDIR');
  1123.     }
  1124.     return '/tmp';
  1125. }
  1126.  
  1127. // }}}
  1128. // {{{ my_env()
  1129. /*
  1130. (cox) In my system PHP 4.2.1 (both cgi & cli) $_ENV is empty
  1131.       but getenv() does work fine
  1132. */
  1133. function my_env($var)
  1134. {
  1135.     if (is_array($_ENV) && isset($_ENV[$var])) {
  1136.         return $_ENV[$var];
  1137.     }
  1138.     return getenv($var);
  1139. }
  1140.  
  1141. // }}}
  1142. // {{{ detect_install_dirs()
  1143.  
  1144. function detect_install_dirs($_prefix = null) {
  1145.     global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir;
  1146.     if (WINDOWS) {
  1147.         if ($_prefix === null) {
  1148.             $prefix = getcwd();
  1149.         } else {
  1150.             $prefix = $_prefix;
  1151.         }
  1152.  
  1153.         if (!@is_dir($prefix)) {
  1154.             if (@is_dir('c:\php4')) {
  1155.                 $prefix = 'c:\php4';
  1156.             } elseif (@is_dir('c:\php')) {
  1157.                 $prefix = 'c:\php';
  1158.             }
  1159.         }
  1160.  
  1161.         $bin_dir   = '$prefix';
  1162.         $php_dir   = '$prefix\pear';
  1163.         $doc_dir   = '$php_dir\docs';
  1164.         $data_dir  = '$php_dir\data';
  1165.         $test_dir  = '$php_dir\tests';
  1166.         /*
  1167.          * Detects php.exe
  1168.          */
  1169.         if( $t=getenv('PHP_PEAR_PHP_BIN') ){
  1170.                 $php_bin   = $t;
  1171.         } elseif ($t=getenv('PHP_BIN') ) {
  1172.             $php_bin   = $t;
  1173.         } elseif ( $t=which('php') ) {
  1174.             $php_bin = $t;
  1175.         } elseif ( is_file($prefix.'\cli\php.exee') ) {
  1176.             $php_bin = $prefix.'\cli\php.exe';
  1177.         } elseif ( is_file($prefix.'\php.exe') ) {
  1178.             $php_bin = $prefix.'\php.exe';
  1179.         }
  1180.         if( $php_bin && !is_file($php_bin) ){
  1181.             $php_bin = '';
  1182.         } else {
  1183.             if(!ereg(":",$php_bin)){
  1184.                 $php_bin = getcwd().DIRECTORY_SEPARATOR.$php_bin;
  1185.             }
  1186.         }
  1187.         if (!is_file($php_bin)) {
  1188.             if (is_file('c:/php/cli/php.exe')) {
  1189.                 $php_bin = 'c:/php/cli/php.exe';
  1190.             } elseif (is_file('c:/php4/cli/php.exe')) {
  1191.                 $php_bin = 'c:/php4/cli/php.exe';
  1192.             }
  1193.         }
  1194.     } else {
  1195.         if ($_prefix === null) {
  1196.             $prefix    = dirname(PHP_BINDIR);
  1197.         } else {
  1198.             $prefix = $_prefix;
  1199.         }
  1200.         $bin_dir   = '$prefix/bin';
  1201.         $php_dir   = '$prefix/share/pear';
  1202.         $doc_dir   = '$php_dir/docs';
  1203.         $data_dir  = '$php_dir/data';
  1204.         $test_dir  = '$php_dir/tests';
  1205.         // check if the user has installed PHP with PHP or GNU layout
  1206.         if (@is_dir("$prefix/lib/php/.registry")) {
  1207.             $php_dir = '$prefix/lib/php';
  1208.         } elseif (@is_dir("$prefix/share/pear/lib/.registry")) {
  1209.             $php_dir = '$prefix/share/pear/lib';
  1210.             $doc_dir   = '$prefix/share/pear/docs';
  1211.             $data_dir  = '$prefix/share/pear/data';
  1212.             $test_dir  = '$prefix/share/pear/tests';
  1213.         } elseif (@is_dir("$prefix/share/php/.registry")) {
  1214.             $php_dir = '$prefix/share/php';
  1215.         }
  1216.     }
  1217. }
  1218.  
  1219. // }}}
  1220. // {{{ displayHTMLHeader
  1221.  
  1222. function displayHTMLHeader()
  1223. {
  1224. ?>
  1225. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  1226. <html>
  1227. <head>
  1228.  <title>PEAR :: Installer :: Go-PEAR</title>
  1229.  <style type="text/css">
  1230.  <!--
  1231.     a {
  1232.         color:#000000;
  1233.         text-decoration: none;
  1234.     }
  1235.     a:visited {
  1236.         color:#000000;
  1237.         text-decoration: none;
  1238.     }
  1239.     a:active {
  1240.         color:#000000;
  1241.         text-decoration: none;
  1242.     }
  1243.     a:hover {
  1244.         color:#000000;
  1245.         text-decoration: underline;
  1246.     }
  1247.  
  1248.     a.green {
  1249.         color:#006600;
  1250.         text-decoration: none;
  1251.     }
  1252.     a.green:visited {
  1253.         color:#006600;
  1254.         text-decoration: none;
  1255.     }
  1256.     a.green:active {
  1257.         color:#006600;
  1258.         text-decoration: none;
  1259.     }
  1260.     a.green:hover {
  1261.         color:#006600;
  1262.         text-decoration: underline;
  1263.     }
  1264.  
  1265.     body, td, th {
  1266.         font-family: verdana,arial,helvetica,sans-serif;
  1267.         font-size: 90%;
  1268.     }
  1269.  
  1270.     p {
  1271.         font-family: verdana,arial,helvetica,sans-serif;
  1272.     }
  1273.  
  1274.     th.pack {
  1275.         color: #FFFFFF;
  1276.         background: #009933;
  1277.         text-align: right;
  1278.     }
  1279.  
  1280.     td.package_info_title {
  1281.         color: #006600;
  1282.         font-weight: bold;
  1283.     }
  1284.  
  1285.     th.others {
  1286.         color: #006600;
  1287.         text-align: left;
  1288.     }
  1289.  
  1290.     em {
  1291.         font-weight: bold;
  1292.         font-style: italic;
  1293.     }
  1294.  
  1295.     .green {
  1296.         color: #006600;
  1297.     }
  1298.     .red {
  1299.         color: #006600;
  1300.     }
  1301.  
  1302.     span.headline {
  1303.         font-family: verdana,arial,helvetica,sans-serif;
  1304.         font-size: 125%;
  1305.         font-weight: bold;
  1306.         color: #ffffff;
  1307.     }
  1308.  
  1309.     span.title {
  1310.         font-family: verdana,arial,helvetica,sans-serif;
  1311.         font-size: 110%;
  1312.         font-weight: bold;
  1313.         color: #006600;
  1314.     }
  1315.  
  1316.     .newsDate {
  1317.         font-size: 85%;
  1318.         font-style: italic;
  1319.         color: #66cc66;
  1320.     }
  1321.  
  1322.     .compact {
  1323.         font-family: arial, helvetica, sans-serif;
  1324.         font-size: 90%;
  1325.     }
  1326.  
  1327.     .menuWhite {
  1328.         font-family: verdana,arial,helvetica,sans-serif;
  1329.         font-size: 75%;
  1330.         color: #ffffff;
  1331.     }
  1332.     .menuBlack {
  1333.         font-family: verdana,arial,helvetica,sans-serif;
  1334.         text-decoration: none;
  1335.         font-weight: bold;
  1336.         font-size: 75%;
  1337.         color: #000000;
  1338.     }
  1339.  
  1340.     .sidebar {
  1341.         font-size: 85%;
  1342.     }
  1343.  
  1344.     code, pre, tt {
  1345.         font-family: Courier, "Courier New", monospace;
  1346.         font-size: 90%;
  1347.     }
  1348.  
  1349.     pre.php {
  1350.         border-color:       black;
  1351.         border-style:       dashed;
  1352.         border-width:       1px;
  1353.         background-color:   #eeeeee;
  1354.         padding:            5px;
  1355.     }
  1356.  
  1357.     h1 {
  1358.         font-family: verdana,arial,helvetica,sans-serif;
  1359.         font-size: 140%;
  1360.         font-weight: bold;
  1361.         color: #006600;
  1362.     }
  1363.  
  1364.     h2 {
  1365.         font-family: verdana,arial,helvetica,sans-serif;
  1366.         font-size: 125%;
  1367.         font-weight: bold;
  1368.         color: #006600;
  1369.     }
  1370.  
  1371.     h3 {
  1372.         font-family: verdana,arial,helvetica,sans-serif;
  1373.         font-size: 110%;
  1374.         font-weight: bold;
  1375.         color: #006600;
  1376.     }
  1377.  
  1378.     small {
  1379.         font-family: verdana,arial,helvetica,sans-serif;
  1380.         font-size: 75%;
  1381.     }
  1382.  
  1383.     a.small {
  1384.         font-family: verdana,arial,helvetica,sans-serif;
  1385.         font-size: 75%;
  1386.         text-decoration: none;
  1387.     }
  1388.  
  1389.     .tableTitle {
  1390.         font-family: verdana,arial,helvetica,sans-serif;
  1391.         font-weight: bold;
  1392.     }
  1393.  
  1394.     .tableExtras {
  1395.         font-family: verdana,arial,helvetica,sans-serif;
  1396.         font-size: 85%;
  1397.         color: #FFFFFF;
  1398.     }
  1399.  
  1400.     input {
  1401.         font-family: verdana,arial,helvetica,sans-serif;
  1402.     }
  1403.  
  1404.     textarea {
  1405.         font-family: verdana,arial,helvetica,sans-serif;
  1406.     }
  1407.  
  1408.     input.small, select.small {
  1409.         font-family: verdana,arial,helvetica,sans-serif;
  1410.         font-size: 75%;
  1411.     }
  1412.  
  1413.     textarea.small {
  1414.         font-family: verdana,arial,helvetica,sans-serif;
  1415.         font-size: 75%;
  1416.     }
  1417.  
  1418.     form {
  1419.         margin-bottom : 0;
  1420.     }
  1421.  -->
  1422.  </style>
  1423.  <meta name="description" content="This is the Web Interface of the PEAR Installer" />
  1424. </head>
  1425.  
  1426. <body   topmargin="0" leftmargin="0"
  1427.         marginheight="0" marginwidth="0"
  1428.         bgcolor="#ffffff"
  1429.         text="#000000"
  1430.         link="#006600"
  1431.         alink="#cccc00"
  1432.         vlink="#003300"
  1433. >
  1434. <?php
  1435. }
  1436.  
  1437. // }}}
  1438. // {{{ displayHTML
  1439.  
  1440. function displayHTML($page = 'Welcome', $data = array())
  1441. {
  1442.     global $pfc_packages;
  1443.  
  1444.     displayHTMLHeader();
  1445.  
  1446. ?>
  1447. <a name="TOP" /></a>
  1448. <table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  1449.   <tr bgcolor="#339900">
  1450.     <td align="left" width="120">
  1451.       <img src="<?php echo basename(__FILE__); ?>?action=img&img=pearlogo" width="104" height="50" vspace="2" hspace="5" alt="PEAR">
  1452.     </td>
  1453.     <td align="left" valign="middle" width="20">
  1454.        
  1455.     </td>
  1456.     <td align="left" valign="middle">
  1457.       <span class="Headline">Go-PEAR</span>
  1458.     </td>
  1459.   </tr>
  1460.  
  1461.   <tr bgcolor="#003300"><td colspan="3"></td></tr>
  1462.  
  1463.   <tr bgcolor="#006600">
  1464.     <td align="right" valign="top" colspan="3">
  1465.         <span style="color: #ffffff">Version <?php echo GO_PEAR_VER; ?></span> <br />
  1466.     </td>
  1467.   </tr>
  1468.  
  1469.   <tr bgcolor="#003300"><td colspan="3"></td></tr>
  1470. </table>
  1471.  
  1472.  
  1473. <table cellpadding="0" cellspacing="0" width="100%">
  1474.  <tr valign="top">
  1475.   <td bgcolor="#f0f0f0" width="100">
  1476.    <table width="200" border="0" cellpadding="4" cellspacing="0">
  1477.     <tr valign="top">
  1478.      <td style="font-size: 90%" align="left" width="200">
  1479.        <br><br>
  1480.        <img src="<?php echo basename(__FILE__); ?>?action=img&img=smallpear" border="0">
  1481.        <a href="<?php echo basename(__FILE__); ?>?step=Welcome&restart=1" <?php if ($page == 'Welcome') echo ' class="green"'; ?>>
  1482.          Welcome to Go-PEAR
  1483.        </a><br/>
  1484.  
  1485.        <img src="<?php echo basename(__FILE__); ?>?action=img&img=smallpear" border="0">
  1486.        <a href="<?php echo basename(__FILE__); ?>?step=config" <?php if ($page == 'config') echo ' class="green"'; ?>>
  1487.          Configuration
  1488.        </a><br/>
  1489.  
  1490.        <img src="<?php echo basename(__FILE__); ?>?action=img&img=smallpear" border="0">
  1491. <?php if ($page == 'install') echo '<span class="green">'; ?>
  1492.           Complete installtion<br/>
  1493. <?php if ($page == 'install') echo '</span>'; ?>
  1494.  
  1495.      </td>
  1496.     </tr>
  1497.    </table>
  1498.   </td>
  1499.   <td bgcolor="#cccccc" width="1" background="/gifs/checkerboard.gif"></td>
  1500.   <td>
  1501.    <table width="100%" cellpadding="10" cellspacing="0">
  1502.     <tr>
  1503.      <td valign="top">
  1504.  
  1505. <table border="0">
  1506. <tr>
  1507.   <td width="20">
  1508.   </td>
  1509.   <td>
  1510. <?php
  1511.     if ($page == 'error') {
  1512. ?>
  1513.             <span class="title">Error</span><br/>
  1514.             <br/>
  1515. <?php
  1516.         $value = $data;
  1517.         if (preg_match('/ok$/', $value)) {
  1518.             $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  1519.         }
  1520.         if (preg_match('/failed$/', $value)) {
  1521.             $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
  1522.         }
  1523.         if (preg_match('/^install ok:/', $value)) {
  1524.             $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  1525.         }
  1526.         if (preg_match('/^Warning:/', $value)) {
  1527.             $value = '<span style="color: #ff0000">'.$value.'</span>';
  1528.         }
  1529.  
  1530.         echo nl2br($value);
  1531.     } elseif ($page == 'Welcome') {
  1532. ?>
  1533.             <span class="title">Welcome to go-pear <?php echo GO_PEAR_VER; ?>!</span><br/>
  1534.             <br/>
  1535.             Go-pear will install the Web Frontend of the PEAR Installer and all the needed <br/>
  1536.             files. This frontend is your tool for PEAR installation and maintenance.<br/>
  1537.             <br/>
  1538.             Go-pear also lets you download and install the PEAR packages bundled<br/>
  1539.             with PHP: <?php echo implode(', ', $GLOBALS['pfc_packages']); ?>.<br/>
  1540.             <br/>
  1541.             <a href="<?php echo basename(__FILE__); ?>?step=config" class="green">Next >></a>
  1542. <?php
  1543.     } elseif ($page == 'config') {
  1544.         if (!empty($GLOBAL['http_proxy'])) {
  1545.             list($proxy_host, $proxy_port) = explode(':', $GLOBALS['http_proxy']);
  1546.         } else {
  1547.             $proxy_host = $proxy_port = '';
  1548.         }
  1549. ?>
  1550.             <form action="<?php echo basename(__FILE__);?>?step=install" method="post">
  1551.             <span class="title">Configuration</span><br/>
  1552.             <br/>
  1553.             HTTP proxy (host:port):
  1554.             <input type="text" name="proxy[host]" value="<?php echo $proxy_host;?>">
  1555.             <input type="text" name="proxy[port]" value="<?php echo $proxy_port;?>" size="6">
  1556.             <br/><br/><hr/><br/>
  1557.             Below is a suggested file layout for your new PEAR installation. <br/>
  1558.             <br/>
  1559.             <table border="0">
  1560.               <TR>
  1561.                 <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" border="0"></TD>
  1562.                 <TD>
  1563.                     <span class="green">
  1564.                     <b>Note:</b> Make sure that PHP has the permission to access the specified<br/>
  1565.                     directories.<br/><br/>
  1566.                   </span>
  1567.                 </TD>
  1568.               </TR>
  1569.             </table>
  1570.             <TABLE border="0">
  1571. <?php
  1572.     // Display error messages
  1573.         if (isset($GLOBALS['www_errors']) && sizeof($GLOBALS['www_errors']) ) {
  1574.             $www_errors = $GLOBALS['www_errors'];
  1575.             echo "<tr><td>";
  1576.             echo '<span class="red">ERROR(S):</span>';
  1577.             echo "</td></tr>";
  1578.             foreach ($www_errors as $n => $var) {
  1579.                 echo "<tr><td>";
  1580.                 echo '<span class="red">'.$GLOBALS['config_desc'][$n].': </span>';
  1581.                 echo "</td><td>";
  1582.                 echo '<span class="red">'.$www_errors[$n].'</span>';
  1583.                 echo "<br>\n";
  1584.                 echo "</td></tr>\n";
  1585.             }
  1586.         }
  1587.  
  1588.         foreach ($GLOBALS['config_vars'] as $n => $var) {
  1589.             printf('<tr><td>%d. %s</td><td><input type="text" name="config[%s]" value="%s"></td></tr>',
  1590.             $n,
  1591.             $GLOBALS['config_desc'][$var],
  1592.             $var,
  1593.             $GLOBALS[$var]);
  1594.         }
  1595. ?>
  1596.             </TABLE>
  1597.             <br/><hr/><br/>
  1598.             The following PEAR packages are common ones, and can be installed<br/>
  1599.             by go-pear too: <br/>
  1600. <?php    echo implode(', ', $GLOBALS['pfc_packages']);?>            .<br/>
  1601.             <input type="checkbox" name="install_pfc" <?php if($GLOBALS['install_pfc']) echo 'checked';?>> Install those too<br/>
  1602.             <br/><br/>
  1603.             <table border="0">
  1604.               <TR>
  1605.                 <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" border="0"></TD>
  1606.                 <TD>
  1607.                     <span class="green">
  1608.                       <b>Note:</b> Installation might take some time, because go-pear has to download<br/>
  1609.                       all needed files from pear.php.net. Just be patient and wait for the next<br/>
  1610.                       page to load.<br/>
  1611.                   </span>
  1612.                 </TD>
  1613.               </TR>
  1614.             </table>
  1615.             <br>
  1616.             <input type="checkbox" name="BCmode" id="BCmode" checked> Compatibility-Mode for old non-DOM Browsers<br/>
  1617.             <script type="text/javascript">
  1618.             <!--
  1619.                 if (document.getElementById('BCmode')) {
  1620.                     document.getElementById('BCmode').checked = 0;
  1621.                 };
  1622.             // -->
  1623.             </script>
  1624.  
  1625. <?php
  1626.         if (WINDOWS && phpversion() == '4.1.1') {
  1627. ?>
  1628.                     <table border="0">
  1629.                       <TR>
  1630.                         <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" border="0"></TD>
  1631.                         <TD>
  1632.                             <span style="color: #ff0000">
  1633.                               <b>Warning:</b> Your PHP version (4.1.1) might be imcompatible with go-pear due to a bug<br/>
  1634.                               in your PHP binary. If the installation crashes you might want to update your PHP version.</br>
  1635.                           </span>
  1636.                         </TD>
  1637.                       </TR>
  1638.                     </table>
  1639. <?php
  1640.         }
  1641. ?>
  1642.             <br/>
  1643.             <input type="submit" value="Install" onClick="javascript: submitButton.value='Downloading and installing ... please wait ...'" name="submitButton">
  1644.             </form>
  1645. <?php
  1646.     } elseif ($page == 'install') {
  1647. ?>
  1648.             <span class="title">Installation Complete - Summary</span><br/>
  1649. <?php
  1650.         displayHTMLInstallationSummary($data);
  1651.     } elseif ($page == 'preinstall') {
  1652. ?>
  1653.             <span class="title">Installation in progress ...</span><br/>
  1654.             <br/>
  1655.             <script language="javascript">
  1656.             <!--
  1657.  
  1658.                 var progress;
  1659.                 var downlodprogress;
  1660.                 progress = 0;
  1661.                 downloadprogress = 0;
  1662.  
  1663.                 function setprogress(value)
  1664.                 {
  1665.                     progress = value;
  1666.  
  1667.                     prog = document.getElementById('installation_progress');
  1668.                     prog.innerHTML = progress + " %";
  1669.                     progress2 = progress / 10;
  1670.                     progress2 = Math.floor(progress2);
  1671.                     for (i=0; i < 10; i++)
  1672.                         document.getElementById('progress_cell_'+i).style.backgroundColor = "#cccccc";
  1673.                     switch(progress2)
  1674.                     {
  1675.                         case 10:
  1676.                             document.getElementById('progress_cell_9').style.backgroundColor = "#006600";
  1677.                         case  9:
  1678.                             document.getElementById('progress_cell_8').style.backgroundColor = "#006600";
  1679.                         case  8:
  1680.                             document.getElementById('progress_cell_7').style.backgroundColor = "#006600";
  1681.                         case  7:
  1682.                             document.getElementById('progress_cell_6').style.backgroundColor = "#006600";
  1683.                         case  6:
  1684.                             document.getElementById('progress_cell_5').style.backgroundColor = "#006600";
  1685.                         case  5:
  1686.                             document.getElementById('progress_cell_4').style.backgroundColor = "#006600";
  1687.                         case  4:
  1688.                             document.getElementById('progress_cell_3').style.backgroundColor = "#006600";
  1689.                         case  3:
  1690.                             document.getElementById('progress_cell_2').style.backgroundColor = "#006600";
  1691.                         case  2:
  1692.                             document.getElementById('progress_cell_1').style.backgroundColor = "#006600";
  1693.                         case  1:
  1694.                             document.getElementById('progress_cell_0').style.backgroundColor = "#006600";
  1695.                     };
  1696.                 }
  1697.  
  1698.                 function addprogress(value)
  1699.                 {
  1700.                     progress += value;
  1701.                     setprogress(progress);
  1702.                 }
  1703.  
  1704.                 function setdownloadfile(value)
  1705.                 {
  1706.                     setdownloadprogress(0);
  1707.  
  1708.                     prog = document.getElementById('download_file');
  1709.                     prog.innerHTML = 'Downloading '+value+' ...';
  1710.                 };
  1711.  
  1712.                 function setdownloadprogress(value)
  1713.                 {
  1714.                     downloadprogress = value;
  1715.  
  1716.                     prog = document.getElementById('download_progress');
  1717.                     prog.innerHTML = downloadprogress + " %";
  1718.                     progress2 = downloadprogress / 10;
  1719.                     progress2 = Math.floor(progress2);
  1720.                     for (i=0; i < 10; i++)
  1721.                         document.getElementById('download_progress_cell_'+i).style.backgroundColor = "#cccccc";
  1722.                     switch(progress2)
  1723.                     {
  1724.                         case 10:
  1725.                             document.getElementById('download_progress_cell_9').style.backgroundColor = "#006600";
  1726.                         case  9:
  1727.                             document.getElementById('download_progress_cell_8').style.backgroundColor = "#006600";
  1728.                         case  8:
  1729.                             document.getElementById('download_progress_cell_7').style.backgroundColor = "#006600";
  1730.                         case  7:
  1731.                             document.getElementById('download_progress_cell_6').style.backgroundColor = "#006600";
  1732.                         case  6:
  1733.                             document.getElementById('download_progress_cell_5').style.backgroundColor = "#006600";
  1734.                         case  5:
  1735.                             document.getElementById('download_progress_cell_4').style.backgroundColor = "#006600";
  1736.                         case  4:
  1737.                             document.getElementById('download_progress_cell_3').style.backgroundColor = "#006600";
  1738.                         case  3:
  1739.                             document.getElementById('download_progress_cell_2').style.backgroundColor = "#006600";
  1740.                         case  2:
  1741.                             document.getElementById('download_progress_cell_1').style.backgroundColor = "#006600";
  1742.                         case  1:
  1743.                             document.getElementById('download_progress_cell_0').style.backgroundColor = "#006600";
  1744.                     };
  1745.                 };
  1746.  
  1747.             // -->
  1748.             </script>
  1749.             <table style="border-width: 1px; border-color: #000000" cellspacing="0" cellpadding="0">
  1750.             <tr>
  1751.               <td>
  1752.                 <table border="0">
  1753.                   <tr>
  1754.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_0"> </td>
  1755.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_1"> </td>
  1756.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_2"> </td>
  1757.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_3"> </td>
  1758.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_4"> </td>
  1759.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_5"> </td>
  1760.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_6"> </td>
  1761.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_7"> </td>
  1762.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_8"> </td>
  1763.                     <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_9"> </td>
  1764.                     <td bgcolor="#ffffff" width="10" height="20"> </td>
  1765.                     <td bgcolor="#ffffff" height="20" id="installation_progress" class="green">0 %</td>
  1766.                   </tr>
  1767.                 </table>
  1768.                 <br>
  1769.                 <table border="0">
  1770.                   <tr>
  1771.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_0"> </td>
  1772.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_1"> </td>
  1773.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_2"> </td>
  1774.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_3"> </td>
  1775.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_4"> </td>
  1776.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_5"> </td>
  1777.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_6"> </td>
  1778.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_7"> </td>
  1779.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_8"> </td>
  1780.                     <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_9"> </td>
  1781.                     <td bgcolor="#ffffff" width="10" height="20"> </td>
  1782.                     <td bgcolor="#ffffff" height="20" id="download_progress" class="green">0 %</td>
  1783.                     <td bgcolor="#ffffff" width="10" height="20"> </td>
  1784.                     <td bgcolor="#ffffff" height="20" id="download_file" class="green"></td>
  1785.                   </tr>
  1786.                 </table>
  1787.                 <br>
  1788.                 <iframe src="<?php echo basename(__FILE__); ?>?step=install-progress&<?php echo SID;?>" width="700" height="700" frameborder="0" marginheight="0" marginwidth="0"></iframe>
  1789.               </td>
  1790.             </tr>
  1791.             </table>
  1792. <?php
  1793.     }
  1794. ?>
  1795.   </td>
  1796. </tr>
  1797. </table>
  1798.  
  1799.  
  1800. </td>
  1801.     </tr>
  1802.    </table>
  1803.   </td>
  1804.  
  1805.  </tr>
  1806. </table>
  1807. <?php
  1808.     displayHTMLFooter();
  1809. }
  1810.  
  1811. // }}}
  1812. // {{{ displayHTMLFooter
  1813.  
  1814. function displayHTMLFooter()
  1815. {
  1816.     ?>
  1817.     </body>
  1818.     </html>
  1819.     <?php
  1820. };
  1821.  
  1822. // }}}
  1823. // {{{ displayHTMLInstallationSummary
  1824.  
  1825. function displayHTMLInstallationSummary($data = '')
  1826. {
  1827.     $next     = NULL;
  1828.     $prefix   = dirname($GLOBALS['webfrontend_file']);
  1829.     $doc_root = strip_magic_quotes($_SERVER['DOCUMENT_ROOT']);
  1830.     $file_dir = dirname(__FILE__);
  1831.     if ( WINDOWS ) {
  1832.         $prefix   = str_replace('/', '\\', strtolower($prefix));
  1833.         $doc_root = str_replace('/', '\\', strtolower($doc_root));
  1834.         $file_dir = str_replace('/', '\\', strtolower($file_dir));
  1835.     }
  1836.  
  1837.     if ($doc_root && substr($prefix, 0, strlen($doc_root)) == $doc_root) {
  1838.         $next = substr($prefix, strlen($doc_root)).'/index.php';
  1839.     } else if ($file_dir && substr($prefix, 0, strlen($file_dir)) == $file_dir) {
  1840.         $next = substr($prefix, strlen($file_dir)).'/index.php';
  1841.     }
  1842.  
  1843.     if ($data) {
  1844.         echo "<br/>".$data;
  1845.     }
  1846. ?>
  1847.             <br/>
  1848.             <table border="0">
  1849.               <TR>
  1850.                 <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" border="0"></TD>
  1851.                 <TD>
  1852.                     <span class="green">
  1853.                   <b>Note:</b> To use PEAR without any problems you need to add your<br/>
  1854.                   PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br>
  1855.                   to your <a href="http://www.php.net/manual/en/configuration.directives.php#ini.include_path">include_path</a>.<br/>
  1856.                       <br/>
  1857.                   Using a .htaccess file or directly edit httpd.conf would be working solutions<br/>
  1858.                   for Apache running servers, too.<br/>
  1859.                   </span>
  1860.                 </TD>
  1861.               </TR>
  1862.             </table>
  1863.             <br/>
  1864.             For more information about PEAR, see:<br/>
  1865.             <a href="http://pear.php.net/faq.php" target="_new" class="green">PEAR FAQ</a><br/>
  1866.             <a href="http://pear.php.net/manual/" target="_new" class="green">PEAR Manual</a><br/>
  1867.             <br/>
  1868.             Thanks for using go-pear!<br/>
  1869.             <br/>
  1870. <?php
  1871.     if ($next === NULL) {
  1872. ?>
  1873.                     <table border="0">
  1874.                       <TR>
  1875.                         <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&img=note" border="0"></TD>
  1876.                         <TD>
  1877.                             <span style="color: #ff0000">
  1878.                             <b>Warning:</b> Go-PEAR was not able to determine the URL to the newly<br/>
  1879.                             installed Web Frontend of the PEAR Installer. Please access it manually.<br/>
  1880.                             Since you specified the prefix, you should know how to do so.<br/>
  1881.                           </span>
  1882.                         </TD>
  1883.                       </TR>
  1884.                     </table>
  1885. <?php
  1886.     } else {
  1887.         if ($_GET['step'] == 'install-progress') {
  1888. ?>
  1889.                         <a href="<?php echo $next;?>" class="green" target="_parent">Start Web Frontend of the PEAR Installer >></a>
  1890. <?php
  1891.         } else {
  1892. ?>
  1893.                         <a href="<?php echo $next;?>" class="green">Start Web Frontend of the PEAR Installer >></a>
  1894. <?php
  1895.         }
  1896.     }
  1897. }
  1898.  
  1899. // }}}
  1900. // {{{ strip_magic_quotes
  1901.  
  1902. function strip_magic_quotes($value)
  1903. {
  1904.     if (ini_get('magic_quotes_gpc')) {
  1905.         return stripslashes($value);
  1906.     }
  1907.     return $value;
  1908. };
  1909.  
  1910. // }}}
  1911. // {{{ showImage
  1912.  
  1913. function showImage($img)
  1914. {
  1915.     $images = array(
  1916.         'smallpear' => array(
  1917.             'type' => 'gif',
  1918.             'data' => 'R0lGODlhEQATAMQAAAAAACqUACiTAC2WAC+YAzKZBTSaBsHgszOZADCYADmcB4TCZp3Ohtfrzd/v1+by4PD47DaaAz+fDUijF2WyOlCoHvT58VqtJPn893y+S/v9+f7//f3+/Pz9+////////ywAAAAAEQATAAAFkqAnjiR5NGXqcdpCoapnMVRdWbEHUROVVROYalHJTCaVAKWTcjAUGckgQY04SJAFMhJJIL5e4a5I6X6/gwlkRIwOzucAY9SYZBRvOCKheIwYFxR5enxCLhVeemAHbBQVg4SMIoCCinsKVyIOdlKKAhQcJFpGiWgFQiIYPxeJCQEEcykcDIgDAwYUkjEWB70NGykhADs=',
  1919.             ),
  1920.         'pearlogo' => array(
  1921.             'type' => 'gif',
  1922.             'data' => 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEekFluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/ICCOZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1AuiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoSDxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIWWQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFEAWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSKkbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEpypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQs+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzcYpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3wQAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDVKwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBET9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BPPZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhBdAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYiWHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAWdgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO906ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgUA3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GGKW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRqvzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQGHcs/RRdiUDPHA33oADEAIAOw==',
  1923.             ),
  1924.         'note' => array(
  1925.             'type' => 'png',
  1926.             'data' => 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAAAAADFHGIkAAAAAmJLR0QAAKqNIzIAAAEESURBVHjaZZIhksMwDEV9voWFSwsLA0MLDf8VdARBUUNBQ1FBHcErZ5M0baXJjOPnb0vfLuMMn3H+lWMgBKL89A1Eq9Q9IrwB+gIOsnMPBR8giMclguQfBGS8x5xIoPQxnxqb4LL/eQ4l2AVNONP2ZshLCqJ3qqzWtT5pNgNnLU4OcNbuiqaLmFmHGhJ0TCMC99+f2wphlhaOYjuQVc0IIzLH2BRWfQoWsNSjct8AVop4rF3belTuVAb3MRj6kLrcTwtIy+g03V1vC57t1XrMzqfP5pln5yLTkk7+5UhstvOni1X3ixLEdf2c36+W0Q7kOb48hnSRLI/XdNPfX4kpMkgP5R+elfdkDPprQgAAAEN0RVh0U29mdHdhcmUAQCgjKUltYWdlTWFnaWNrIDQuMi44IDk5LzA4LzAxIGNyaXN0eUBteXN0aWMuZXMuZHVwb250LmNvbZG6IbgAAAAqdEVYdFNpZ25hdHVyZQAzYmQ3NDdjNWU0NTgwNzAwNmIwOTBkZDNlN2EyNmM0NBTTk/oAAAAOdEVYdFBhZ2UAMjR4MjQrMCswclsJMQAAAABJRU5ErkJggg==',
  1927.             ),
  1928.         );
  1929.  
  1930.     Header('Content-Type: image/'.$images[$img]['type']);
  1931.     echo base64_decode($images[$img]['data']);
  1932. };
  1933.  
  1934. // }}}
  1935. // {{{ displayHTMLProgress
  1936.  
  1937. function displayHTMLProgress($progress)
  1938. {
  1939.     if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1940.         return;
  1941.     };
  1942.     $msg = ob_get_contents();
  1943.     ob_end_clean();
  1944.  
  1945.     $msg = explode("\n", $msg);
  1946.     foreach($msg as $key => $value) {
  1947.         if (preg_match('/ok$/', $value)) {
  1948.             $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  1949.         };
  1950.         if (preg_match('/failed$/', $value)) {
  1951.             $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
  1952.         };
  1953.         if (preg_match('/^install ok:/', $value)) {
  1954.             $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  1955.         };
  1956.         if (preg_match('/^Warning:/', $value)) {
  1957.             $value = '<span style="color: #ff0000">'.$value.'</span>';
  1958.         };
  1959.         $msg[$key] = $value;
  1960.     };
  1961.     $msg = implode('<br>', $msg);
  1962.  
  1963.     $msg.='<script type="text/javascript"> parent.setprogress('.((int) $progress).');  </script>';
  1964.  
  1965.     echo $msg;
  1966.     ob_start();
  1967. };
  1968.  
  1969. // }}}
  1970. // {{{ displayHTMLDownloadProgress
  1971.  
  1972. function displayHTMLDownloadProgress($progress)
  1973. {
  1974.     if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1975.         return;
  1976.     };
  1977.     $msg = ob_get_contents();
  1978.     ob_end_clean();
  1979.  
  1980.     echo '<script type="text/javascript"> parent.setdownloadprogress('.((int) $progress).');  </script>';
  1981.  
  1982.     ob_start();
  1983.     echo $msg;
  1984. };
  1985.  
  1986. // }}}
  1987. // {{{ displayHTMLSetDownload
  1988.  
  1989. function displayHTMLSetDownload($file)
  1990. {
  1991.     if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1992.         return;
  1993.     };
  1994.     $msg = ob_get_contents();
  1995.     ob_end_clean();
  1996.  
  1997.     echo '<script type="text/javascript"> parent.setdownloadfile("'.$file.'");  </script>';
  1998.  
  1999.     ob_start();
  2000.     echo $msg;
  2001. };
  2002.  
  2003. // }}}
  2004. // {{{ win32BrowseForFolder
  2005.  
  2006. /*
  2007.  * Create a vbs script to browse the getfolder dialog, called
  2008.  * by cscript, if it's available.
  2009.  * $label is the label text in the header of the dialog box
  2010.  *
  2011.  * TODO:
  2012.  * - Do not show Control panel
  2013.  * - Replace WSH with calls to w32 as soon as callbacks work
  2014.  * @Author Pierrre-Alain Joye
  2015.  */
  2016. function win32BrowseForFolder ( $label )
  2017. {
  2018.     global $ptmp;
  2019.     static $wshSaved=false;
  2020.     static $cscript='';
  2021. $wsh_browserfolder = 'Option Explicit
  2022. Dim ArgObj, var1, var2, sa, sFld
  2023. Set ArgObj = WScript.Arguments
  2024. Const BIF_EDITBOX = &H10
  2025. Const BIF_NEWDIALOGSTYLE = &H40
  2026. Const BIF_RETURNONLYFSDIRS   = &H0001
  2027. Const BIF_DONTGOBELOWDOMAIN  = &H0002
  2028. Const BIF_STATUSTEXT         = &H0004
  2029. Const BIF_RETURNFSANCESTORS  = &H0008
  2030. Const BIF_VALIDATE           = &H0020
  2031. Const BIF_BROWSEFORCOMPUTER  = &H1000
  2032. Const BIF_BROWSEFORPRINTER   = &H2000
  2033. Const BIF_BROWSEINCLUDEFILES = &H4000
  2034. Const OFN_LONGNAMES = &H200000
  2035. Const OFN_NOLONGNAMES = &H40000
  2036. Const ssfDRIVES = &H11
  2037. Const ssfNETWORK = &H12
  2038. Set sa = CreateObject("Shell.Application")
  2039. var1=ArgObj(0)
  2040. Set sFld = sa.BrowseForFolder(0, var1, BIF_EDITBOX + BIF_VALIDATE + BIF_BROWSEINCLUDEFILES + BIF_RETURNFSANCESTORS+BIF_NEWDIALOGSTYLE , ssfDRIVES )
  2041. if not sFld is nothing Then
  2042.     if not left(sFld.items.item.path,1)=":" Then
  2043.         WScript.Echo sFld.items.item.path
  2044.     Else
  2045.         WScript.Echo "invalid"
  2046.     End If
  2047. Else
  2048.     WScript.Echo "cancel"
  2049. End If
  2050. ';
  2051.     if( !$wshSaved){
  2052.         $cscript = $ptmp.DIRECTORY_SEPARATOR."bf.vbs";
  2053.         $fh = fopen($cscript,"wb+");
  2054.         fwrite($fh,$wsh_browserfolder,strlen($wsh_browserfolder));
  2055.         fclose($fh);
  2056.         $wshSaved  = true;
  2057.     }
  2058.     exec('cscript '.$cscript.' "'.$label.'" //noLogo',$arPath);
  2059.     if($arPath[0]=='' || $arPath[0]=='cancel'){
  2060.         return '';
  2061.     } elseif ($arPath[0]=='invalid') {
  2062.         echo "Invalid Path.\n";
  2063.         return '';
  2064.     }
  2065.     return $arPath[0];
  2066. }
  2067.  
  2068. // }}}
  2069. // {{{ win32CreateRegEnv
  2070.  
  2071. /*
  2072.  * Generates a registry addOn for Win32 platform
  2073.  * This addon set PEAR environment variables
  2074.  * @Author Pierrre-Alain Joye
  2075.  */
  2076. function win32CreateRegEnv(){
  2077.     global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir;
  2078.     $nl = "\r\n";
  2079.     $reg ='REGEDIT4'.$nl.
  2080.             '[HKEY_CURRENT_USER\Environment]'.$nl.
  2081.             '"PHP_PEAR_SYSCONF_DIR"="'.addslashes($prefix).'"'.$nl.
  2082.             '"PHP_PEAR_INSTALL_DIR"="'.addslashes($php_dir).'"'.$nl.
  2083.             '"PHP_PEAR_DOC_DIR"="'.addslashes($doc_dir).'"'.$nl.
  2084.             '"PHP_PEAR_BIN_DIR"="'.addslashes($bin_dir).'"'.$nl.
  2085.             '"PHP_PEAR_DATA_DIR"="'.addslashes($data_dir).'"'.$nl.
  2086.             '"PHP_PEAR_PHP_BIN"="'.addslashes($php_bin).'"'.$nl.
  2087.             '"PHP_PEAR_TEST_DIR"="'.addslashes($test_dir).'"'.$nl;
  2088.     //$path = dirname(__FILE__).DIRECTORY_SEPARATOR;
  2089.     $fh = fopen($prefix.DIRECTORY_SEPARATOR.'PEAR_ENV.reg','wb');
  2090.     if($fh){
  2091.         fwrite($fh, $reg ,strlen($reg));
  2092.         fclose($fh);
  2093.         echo "
  2094.  
  2095. * WINDOWS ENVIRONMENT VARIABLES *
  2096. For convenience, a REG file is available under $prefix\\PEAR_ENV.reg .
  2097. This file creates ENV variables for the current user.
  2098.  
  2099. Double-click this file to add it to the current user registry.
  2100.  
  2101. ";
  2102.     }
  2103. }
  2104.  
  2105. // }}}
  2106. // {{{ win32DetectPHPSAPI
  2107.  
  2108. /*
  2109.  * Try to detect the kind of SAPI used by the
  2110.  * the given php.exe.
  2111.  * @Author Pierrre-Alain Joye
  2112.  */
  2113. function win32DetectPHPSAPI()
  2114. {
  2115.     global $php_bin;
  2116.     if($php_bin!=''){
  2117.         exec($php_bin.' -v', $res);
  2118.         if(is_array($res)) {
  2119.             if( isset($res[0]) && strpos($res[0],"(cli)")) {
  2120.                 return 'cli';
  2121.             }
  2122.             if( isset($res[0]) && strpos($res[0],"cgi")) {
  2123.                 return 'cgi';
  2124.             } else {
  2125.                 return 'unknown';
  2126.             }
  2127.         }
  2128.     }
  2129. }
  2130.  
  2131. // }}}
  2132. // {{{ getPhpiniPath
  2133.  
  2134. /*
  2135.  * Get the php.ini file used with the current
  2136.  * process or with the given php.exe
  2137.  *
  2138.  * Horrible hack, but well ;)
  2139.  *
  2140.  * Not used yet, will add the support later
  2141.  * @Author Pierre-Alain Joye <paj@pearfr.org>
  2142.  */
  2143. function getPhpiniPath()
  2144. {
  2145.     $pathIni = get_cfg_var('cfg_file_path');
  2146.     if( $pathIni && is_file($pathIni) ){
  2147.         return $pathIni;
  2148.     }
  2149.  
  2150.     // Oh well, we can keep this too :)
  2151.     // I dunno if get_cfg_var() is safe on every OS
  2152.     if (WINDOWS) {
  2153.         // on Windows, we can be pretty sure that there is a php.ini
  2154.         // file somewhere
  2155.         do {
  2156.             $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini';
  2157.             if ( @file_exists($php_ini) ) break;
  2158.             $php_ini = 'c:\winnt\php.ini';
  2159.             if ( @file_exists($php_ini) ) break;
  2160.             $php_ini = 'c:\windows\php.ini';
  2161.         } while (false);
  2162.     } else {
  2163.         $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini';
  2164.     }
  2165.  
  2166.     if( @is_file($php_ini) ){
  2167.         return $php_ini;
  2168.     }
  2169.  
  2170.     // We re running in hackz&troubles :)
  2171.     ob_implicit_flush(false);
  2172.     ob_start();
  2173.     phpinfo(INFO_GENERAL);
  2174.     $strInfo = ob_get_contents ();
  2175.     ob_end_clean();
  2176.     ob_implicit_flush(true);
  2177.  
  2178.     if ( php_sapi_name() != 'cli' ) {
  2179.         $strInfo = strip_tags($strInfo,'<td>');
  2180.         $arrayInfo  = explode("</td>", $strInfo );
  2181.         $cli = false;
  2182.     } else {
  2183.         $arrayInfo = explode("\n",$strInfo);
  2184.         $cli = true;
  2185.     }
  2186.  
  2187.     foreach($arrayInfo as $val){
  2188.         if ( strpos($val,"php.ini") ) {
  2189.             if($cli){
  2190.                 list(,$pathIni) = explode('=>',$val);
  2191.             } else {
  2192.                 $pathIni = strip_tags(trim($val) );
  2193.             }
  2194.             $pathIni = trim($pathIni);
  2195.             if(is_file($pathIni)){
  2196.                 return $pathIni;
  2197.             }
  2198.         }
  2199.     }
  2200.  
  2201.     return false;
  2202. }
  2203.  
  2204. // }}}
  2205. // {{{ alterPhpIni
  2206.  
  2207. /*
  2208.  * Not optimized, but seems to work, if some nice
  2209.  * peardev will test it? :)
  2210.  *
  2211.  * @Author Pierre-Alain Joye <paj@pearfr.org>
  2212.  */
  2213. function alterPhpIni($pathIni='')
  2214. {
  2215.     global $php_dir, $prefix;
  2216.  
  2217.     $iniSep = WINDOWS?';':':';
  2218.  
  2219.     if( $pathIni=='' ){
  2220.         $pathIni =  getphpinipath();
  2221.     }
  2222.  
  2223.     $arrayIni = file($pathIni);
  2224.     $i=0;
  2225.     $found=0;
  2226.  
  2227.     // Looks for each active include_path directives
  2228.     foreach ( $arrayIni as $iniLine ) {
  2229.         $iniLine = trim($iniLine);
  2230.         $iniLine = str_replace(array("\n","\r"),array(),$iniLine);
  2231.         if( preg_match("/^include_path/",$iniLine) ){
  2232.             $foundAt[] = $i;
  2233.             $found++;
  2234.         }
  2235.         $i++;
  2236.     }
  2237.  
  2238.     if ( $found ) {
  2239.         $includeLine = $arrayIni[$foundAt[0]];
  2240.         list(,$currentPath)=explode('=',$includeLine);
  2241.  
  2242.         $currentPath = trim($currentPath);
  2243.         if(substr($currentPath,0,1)=='"'){
  2244.             $currentPath = substr($currentPath,1,strlen($currentPath)-2);
  2245.         }
  2246.  
  2247.         $arrayPath = explode($iniSep, $currentPath);
  2248.         if( $arrayPath[0]=='.' ){
  2249.             $newPath[0] = '.';
  2250.             $newPath[1] = $php_dir;
  2251.             array_shift($arrayPath);
  2252.         } else {
  2253.             $newPath[0] = $php_dir;
  2254.         }
  2255.  
  2256.         foreach( $arrayPath as $path ){
  2257.             $newPath[]= $path;
  2258.         }
  2259.     } else {
  2260.         $newPath[0] = '.';
  2261.         $newPath[1] = $php_dir;
  2262.  
  2263.     }
  2264.     $nl = WINDOWS?"\r\n":"\n";
  2265.     $includepath = 'include_path="'.implode($iniSep,$newPath).'"';
  2266.     $newInclude =   "$nl$nl;***** Added by go-pear$nl".
  2267.                     $includepath.
  2268.                     $nl.";*****".
  2269.                     $nl.$nl;
  2270.  
  2271.     $arrayIni[$foundAt[0]] =  $newInclude;
  2272.  
  2273.     for( $i=1; $i<$found; $i++){
  2274.         $arrayIni[$foundAt[$i]]=';'.trim($arrayIni[$foundAt[$i]]);
  2275.     }
  2276.  
  2277.     $newIni = implode("",$arrayIni);
  2278.     if ( !($fh = @fopen($pathIni, "wb+")) ){
  2279.         $prefixIni = $prefix.DIRECTORY_SEPARATOR."php.ini-gopear";
  2280.         $fh = fopen($prefixIni, "wb+");
  2281.         if ( !$fh ) {
  2282.             echo
  2283. "
  2284. ******************************************************************************
  2285. WARNING!  I cannot write to $pathIni nor in $prefix/php.ini-gopear. Please
  2286. modify manually your php.ini by adding:
  2287.  
  2288. $includepath
  2289.  
  2290. ";
  2291.             return false;
  2292.         } else {
  2293.             fwrite($fh, $newIni, strlen($newIni));
  2294.             fclose($fh);
  2295.             echo
  2296. "
  2297. ******************************************************************************
  2298. WARNING!  I cannot write to $pathIni, but I succesfully created a php.ini
  2299. under <$prefix/php.ini-gopear>. Please replace the file <$pathIni> with
  2300. <$prefixIni> or modify your php.ini by adding:
  2301.  
  2302. $includepath
  2303.  
  2304. ";
  2305.  
  2306.         }
  2307.     } else {
  2308.         fwrite($fh, $newIni, strlen($newIni));
  2309.         fclose($fh);
  2310.         echo "
  2311. php.ini <$pathIni> include_path updated.
  2312. ";
  2313.     }
  2314.     return true;
  2315. }
  2316. ?>
  2317.